home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWTxtShp.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.4 KB  |  158 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWTxtShp.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWTXTSHP_H
  11. #define FWTXTSHP_H
  12.  
  13. #ifndef FWBTXTSH_H
  14. #include "FWBTxtSh.h"
  15. #endif
  16.  
  17. #ifndef FWGCONST_H
  18. #include "FWGConst.h"
  19. #endif
  20.  
  21. #if FW_LIB_EXPORT_PRAGMAS
  22. #pragma lib_export on
  23. #endif
  24.  
  25. //========================================================================================
  26. //    class FW_CTextShape
  27. //========================================================================================
  28.  
  29. class FW_CLASS_ATTR FW_CTextShape : public FW_CBaseTextShape
  30. {
  31. public:
  32.     FW_DECLARE_CLASS
  33.  
  34. //----------------------------------------------------------------------------------------
  35. //    Constructors/Destructors
  36. //
  37. public:
  38.  
  39.     enum
  40.     {
  41.         kDefaultAlignment = 
  42.             FW_kTextAlignLeft |
  43.             FW_kTextAlignTop |
  44.             FW_kTextAlignUseSpecifiedPos
  45.     };
  46.  
  47.     FW_CTextShape();
  48.     FW_CTextShape(const FW_CString& string,
  49.                   FW_CFixed xPos,
  50.                   FW_CFixed yPos,
  51.                   const FW_PFont& font = FW_kNormalFont,
  52.                   FW_TextAlignment textAlignment = kDefaultAlignment,
  53.                   const FW_PInk& ink = FW_kNormalTextInk);
  54.                   
  55.     FW_CTextShape(FW_CTextReader* textReader,
  56.                   FW_CFixed xPos,
  57.                   FW_CFixed yPos,
  58.                   const FW_PFont& font = FW_kNormalFont,
  59.                   FW_TextAlignment textAlignment = kDefaultAlignment,
  60.                   const FW_PInk& ink = FW_kNormalTextInk);
  61.                     
  62.     FW_CTextShape(const FW_CTextShape& other);
  63.     FW_CTextShape(FW_CReadableStream& archive);
  64.     
  65.     virtual ~ FW_CTextShape();
  66.     
  67. //----------------------------------------------------------------------------------------
  68. //    Operators
  69. //
  70. public:
  71.     FW_CTextShape& operator=(const FW_CTextShape& other);
  72.     
  73. //----------------------------------------------------------------------------------------
  74. //    Inherited API
  75. //
  76. public:
  77.     // ----- Rendering -----
  78.     virtual void                 Render(FW_CGraphicContext& gc) const;
  79.                             
  80.     // ----- Transform -----
  81.     virtual void                Transform(Environment* ev, ODTransform* odTransform);
  82.     virtual void                InverseTransform(Environment* ev, ODTransform* odTransform);
  83.  
  84.     virtual void                MoveShape(FW_CFixed deltaX, FW_CFixed deltaY);
  85.     virtual void                MoveShapeTo(FW_CFixed x, FW_CFixed y);
  86.  
  87.     virtual void                Inset(FW_CFixed x, FW_CFixed y);
  88.     
  89.     // ----- Copying -----
  90.     virtual FW_CShape*            Copy() const;
  91.     
  92.     // ----- Geometry -----
  93.     virtual void                 GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const;
  94.     
  95.     // ----- Flatten -----
  96.     virtual void                Flatten(FW_CWritableStream& archive) const;
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    New API
  100. //
  101. public:
  102.     // ----- Rendering -----
  103.     static void                 RenderText(FW_CGraphicContext& gc,
  104.                                               FW_CTextReader* textReader,
  105.                                               const FW_CPoint& position,
  106.                                               const FW_PFont& font,
  107.                                               FW_TextAlignment textAlignment = kDefaultAlignment,
  108.                                               const FW_PInk& ink = FW_kNormalTextInk);
  109.  
  110.     static void                 RenderText(FW_CGraphicContext& gc,
  111.                                               const FW_CString& string,
  112.                                               const FW_CPoint& position,
  113.                                               const FW_PFont& font,
  114.                                               FW_TextAlignment textAlignment = kDefaultAlignment,
  115.                                               const FW_PInk& ink = FW_kNormalTextInk);
  116.  
  117.     // ----- Measurement -----
  118.     FW_CPoint                    TextExtent(FW_CGraphicContext& gc) const;
  119.     
  120.     static FW_CPoint            TextExtent(FW_CGraphicContext& gc,
  121.                                               FW_CTextReader* textReader,
  122.                                               const FW_PFont& font);
  123.     static FW_CPoint            TextExtent(FW_CGraphicContext& gc,
  124.                                               const FW_CString& string,
  125.                                               const FW_PFont& font);
  126.     
  127.     // ----- Archiving -----
  128.     static void*                 Read(FW_CReadableStream& archive);
  129.  
  130.     // ----- Geometry -----
  131.     FW_CPoint                    GetPosition() const
  132.                                     {return fPosition;}
  133.  
  134.     void                        SetPosition(FW_CFixed xPos, FW_CFixed yPos)
  135.                                     {fPosition.x = xPos, fPosition.y = yPos;}
  136.  
  137.     FW_TextAlignment            GetTextAlignment() const
  138.                                     {return fTextAlignment;}                                
  139.     void                        SetTextAlignment(FW_TextAlignment textAlignment)
  140.                                     {fTextAlignment = textAlignment;}
  141.     
  142.     void                        GetBaseLine(FW_CGraphicContext& gc,
  143.                                             FW_CPoint& start, FW_CPoint& end) const;
  144.     
  145. //----------------------------------------------------------------------------------------
  146. //    Data Members
  147. //
  148. protected:
  149.     FW_CPoint                    fPosition;
  150.     FW_TextAlignment            fTextAlignment;
  151. };
  152.  
  153. #if FW_LIB_EXPORT_PRAGMAS
  154. #pragma lib_export off
  155. #endif
  156.  
  157. #endif
  158.